﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}

<!DOCTYPE html>


<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>赋码管理</title>
    <link href="~/lib/layui/css/layui.css" rel="stylesheet" />
    @* <script src="~/lib/layui/layui.js"></script> *@
    <script src="~/js/js.cookie.js"></script>
    <script src="~/js/moment.js"></script>
    <script src="~/lib/jquery/dist/jquery.js"></script>
</head>
<body>
    <form class="layui-form" action="">
        <div class="layui-form" lay-filter="filter-test-layer" style="margin: 16px;">
            <div class="demo-Add-container">
                <div class="layui-form-item">
                    <div class="layui-input-group">
                        <div class="layui-input-prefix" style="left:28px">
                            条码格式
                        </div>
                        <div style="left:30px;width:197px">
                            <select id="QUCodeFormat" lay-filter="testSelect">
                                <option value="0">QR二维码</option>
                                <option value="1">UPC码</option>
                            </select>
                            
                        </div>
                        <div class="layui-input-prefix" style="left:70px">
                            条码类型
                        </div>
                        <div style="left:70px;width:197px">
                            <select id="QUCodeType" lay-filter="testSelect">
                                <option value="-1">物料条码</option>
                                <option value="0">物料条码</option>
                                <option value="1">库存条码</option>
                                <option value="2">仓库条码</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-group">
                        <div class="layui-input-prefix" style="left:28px">
                            物料名称
                        </div>
                        <div style="width:220px;left:28px">
                            <input style="width:300px" type="text" id="QUCodeMatterName">
                        </div>
                        <div class="layui-input-prefix" style="left:40px">
                            物料编码
                        </div>
                        <div style="width:220px;left:90px">
                            <input style="width:200px" type="text" id="QUCodeMatterCode">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-group">
                        <div class="layui-input-prefix" style="left:55px">
                            状态
                        </div>
                        <div style="width:220px;left:55px">
                            <input type="radio" name="QUCodeStart" value="0" title="生效" lay-filter="demo-radio-filter" checked>
                            <input type="radio" name="QUCodeStart" value="1" lay-filter="demo-radio-filter" title="失效">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-group">
                        <div class="layui-input-prefix" style="left:26px">
                            条码内容
                        </div>
                        <div style="width:220px;left:27px">
                            <input style="width:50px" type="text" id="QUCodeMatter">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-group">
                        <div class="layui-input-prefix" style="left:55px">
                            备注
                        </div>
                        <div style="width:80px;left:55px">
                            <input style="width:50px" type="text" id="QUCodeRemark">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-group">
                        <div style="width:80px;left:55px">
                            <img id="BarCode" src="" style="width:200px;height:200px;">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>

</body>
</html>
<script>
    var form = layui.form;
    var laypage = layui.laypage;
    var layer = layui.layer;
    var $ = layui.$;
    var laydate = layui.laydate;
    var util = layui.util;
    var obj = {
        quCodeId: 0,
        quCodeType: '',
        quCodeStart: '',
        quCodeRemark: '',
        quCodeMatter: '',
        quCodeFormat: '',
        productManageNode: '',
        productManageName: '',
        barCode: '',
    };
    $(function () {
        Backfill()
    })

    function Backfill() {
        return new Promise(function (resolve, reject) {
            $(document).ready(function () {
                //获取要编辑的销售出库单id，可以通过url参数传递
                var quCodeId = localStorage.getItem("quCodeId");
                console.log(quCodeId);
                //根据id获取赋码管理信息
                if (quCodeId) {
                    $.ajax({
                        type: 'post',
                        url: '@ViewBag.FoundationRead' + "/api/UserLi/SearchShow",
                        data: JSON.stringify({ quCodeId: quCodeId }),
                        async: false,
                        dataType: "json",
                        contentType: "application/json",
                        success: function (res) {
                            if (res.data) {
                                const sellStock = res.data;
                                console.log(sellStock);
                                $('#QUCodeFormat').val(sellStock[0].quCodeFormat);
                                layui.form.render('select');
                                $('#QUCodeType').val(sellStock[0].quCodeType);
                                layui.form.render('select');
                                $('#QUCodeMatterName').val(sellStock[0].productManageName);
                                $('#QUCodeMatterCode').val(sellStock[0].productManageNode);
                                $('[name="QUCodeStart"]').val(sellStock[0].quCodeStart);
                                if (sellStock[0].quCodeStart == 1) {
                                    $('[name="QUCodeStart"]').prop('checked',true);
                                }
                                $('#QUCodeMatter').val(sellStock[0].quCodeMatter);
                                $('#QUCodeRemark').val(sellStock[0].quCodeRemark);
                                $('#BarCode').val(sellStock[0].barCode);
                                $("#BarCode").prop("src", sellStock[0].barCode)
                                resolve(sellStock);

                            } else {
                                layer.msg(res.message);
                            }
                            form.render();
                        }
                    })
                }
            })
        })
    }
</script>